package com.yiran.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yiran.dao.AdminBean;
import com.yiran.model.AdminClass;

public class UserAddServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {

		response.setContentType("text/html;charset=GBK");
		request.setCharacterEncoding("GBK");

		String name = request.getParameter("usersName");
		String password = request.getParameter("usersPass");
		
		AdminBean ab = new AdminBean();
		AdminClass ac = new AdminClass();
		ac.setAdminName(name);
		ac.setAdminPass(password);
		ab.setAdminInfo(ac);
		try {
			ab.addAdminInfo();
		} catch (Exception e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("/admin/success.jsp").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {

		doGet(request, response);
	}
}
